const { createProxyMiddleware } = require("http-proxy-middleware");

module.exports = function (app) {
    app.use(
        "/api",
        createProxyMiddleware({
            target: "http://localhost:5050",
            pathRewrite: {
                // 重写请求
                "^/api": "/", // 所有以 "/api" 开头的请求，"/api" 都会重写为 "/"
            },
            changeOrigin: true,
        })
    );
};
